package com.weipeep.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import com.weipeep.common.base.CoreServiceImpl;
import com.weipeep.common.dao.ConfigMapper;
import com.weipeep.common.domain.ConfigDO;
import com.weipeep.common.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <pre>
 * </pre>
 * <small> 2018年4月6日 | wangyun</small>
 */
@Service
public class ConfigServiceImpl extends CoreServiceImpl<ConfigMapper, ConfigDO> implements ConfigService {

    @Autowired
    ConfigMapper configMapper;
    @Override
    public ConfigDO getByKey(String k) {
        ConfigDO entity = new ConfigDO();
        entity.setK(k);
        Map<String,Object> map = Maps.newHashMap();
        map.put("k",k);
        return baseMapper.selectByMap(map).get(0);
    }

    @Override
    public String getValuByKey(String k) {
        ConfigDO bean = this.getByKey(k);
        return bean == null ? "" : bean.getV();
    }
}
